
#ifndef TEXTURE_CACHE_H
#define TEXTURE_CACHE_H

// INCLUDES ********************************************************************

#include "Cache.h"

#include "Singleton.h"

#include <string>

// FORWARD DECLARATIONS ********************************************************

namespace Meteor 
{
    class Texture2D;
}

// *****************************************************************************

//! TextureCache
//! 
//! Controlling texture usage, taking care of releasing and loading textures
//! whenever necessary. All loading actions should be done through the texture
//! cache. This is a singleton class, the one and only instance is accessed
//! via TextureCache::Instance()
//! 
// *****************************************************************************

namespace Meteor
{
    class TextureCache : public Cache<Texture2D*>, public Singleton<TextureCache>
    {
        friend class Singleton<TextureCache>;
        
        public:
            //! add an image. if a texture for this image already exists,
            //! this texture will be returned
            Texture2D* AddObject( const std::string& fileName);
            
            void AddObjectAsync( const std::string& fileName, Function* fileAdded=0);
        
        private:
            TextureCache();
            
            //! prevent copies
            TextureCache( const TextureCache&);
            
            const TextureCache& operator=( const TextureCache&);
            
            ~TextureCache();
            
    }; // end of class TextureCache

} // end of namespace Meteor

#endif // TEXTURE_CACHE_H
